﻿using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace revitDemo
{
    internal class 圆锥:RevietBase
    {
        public 圆锥(ExternalCommandData commandData) : base(commandData)
        {



        }

        public override void Test()
        {
            OpenTransaction("33",CreateCone(3,10));
        }


        public Solid CreateCone(double radius, double height)
        {
            XYZ center = XYZ.Zero;
            XYZ px = radius * XYZ.BasisX;
            XYZ pz = height * XYZ.BasisZ;

            List<Curve> profile = new List<Curve>();

            profile.Add(Line.CreateBound(center, px));
            profile.Add(Line.CreateBound(px, pz));
            profile.Add(Line.CreateBound(pz, center));

            CurveLoop curveLoop = CurveLoop.Create(profile);

            Frame frame = new Frame(
              center, XYZ.BasisX, XYZ.BasisY, XYZ.BasisZ);

            Solid cone = GeometryCreationUtilities.CreateRevolvedGeometry(frame, new CurveLoop[] { curveLoop }, 0, 2 * Math.PI);

            return cone;
        }

      
    }
}
